package org.rkuk.kasutil.test.system.stack 
{
	import org.rkuk.kasutil.designPatternTools.AbstractTool;
	import org.rkuk.kasutil.test.system.handler.Handler;
	import org.rkuk.kasutil.test.system.TestThread;
	/**
	 * ...
	 * @author rkuk
	 */
	public class HandlerStack 
	{
		private var testThread_:TestThread;
		
		public function HandlerStack(testThread:TestThread) 
		{
			AbstractTool.makeAbstractClass(this, HandlerStack);
			testThread_ = testThread;
		}
		
		/**
		 * clear the test method buffer
		 */
		public function clearBuffer():void
		{
			AbstractTool.makeAbstractMethod(this, "clearBuffer");
		}
		
		/**
		 * push method into stack to wait for the given event
		 * @param	method
		 * @param	eventTarget
		 * @param	eventType
		 */
		public function pushHandler(handler:Handler):void
		{
			AbstractTool.makeAbstractMethod(this, "pushHandler");
		}
		
		/**
		 * flush the handler which are put in the buffer just now and start the internal event
		 */
		public function startHandlerInBuffer():void
		{
			AbstractTool.makeAbstractMethod(this, "popHandler");
		}
		
		public function dispose():void
		{
			AbstractTool.makeAbstractMethod(this, "dispose");
		}
		
		/**
		 * pop the handler to TestThread to run
		 * @param	handler
		 */
		protected function popHandler(handler:Handler):void
		{
			if(handler!=null)
				testThread_.onStackPop(handler.eventMethod, handler.triggerEvent);
		}
	}
}